package com.example.finance_manager.pages.my;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

import com.example.finance_manager.R;
import com.example.finance_manager.adapter.IncomeAdapter;
import com.example.finance_manager.dao.SalaryDao;
import com.example.finance_manager.models.Salary;

import java.util.ArrayList;
import java.util.List;

public class MyIncomeActivity extends AppCompatActivity {

    private ListView lvIncome;
    private List<Salary> salaries = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_income);

        initView();
        initData();

        IncomeAdapter incomeAdapter = new IncomeAdapter(this, salaries);
        lvIncome.setAdapter(incomeAdapter);
    }

    private void initView() {
        lvIncome = (ListView) findViewById(R.id.lv_my_income);
    }

    private void initData() {
        SalaryDao salaryDao = new SalaryDao(MyIncomeActivity.this);
        salaries = salaryDao.findAll();
    }
}